<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button onclick="xxxx()">点击测试</button>
</body>

<script type="text/javascript">
   function xxxx(){
       const encoder = new TextEncoder();
       const text = '韩朋虎';
       const bytes = encoder.encode(text);
       alert(bytes.length)
    }

</script>
</html>